/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mlbs.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author mckd87
 */
@Entity
@Table(name = "appusage")
@NamedQueries({@NamedQuery(name = "Appusage.findByDateUsed", query = "SELECT a FROM Appusage a WHERE a.dateUsed = :dateUsed"), @NamedQuery(name = "Appusage.findByDuration", query = "SELECT a FROM Appusage a WHERE a.duration = :duration"), @NamedQuery(name = "Appusage.findByUsageId", query = "SELECT a FROM Appusage a WHERE a.usageId = :usageId")})
public class Appusage implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "dateUsed")
    @Temporal(TemporalType.DATE)
    private Date dateUsed;
    @Column(name = "duration")
    private Integer duration;
    @Id
    @Column(name = "usageId", nullable = false)
    private Integer usageId;
    @JoinColumn(name = "userId", referencedColumnName = "userId")
    @ManyToOne
    private Usertable userId;
    @JoinColumn(name = "appId", referencedColumnName = "appId")
    @ManyToOne
    private Application appId;
    @JoinColumn(name = "deviceid", referencedColumnName = "deviceid")
    @ManyToOne
    private Device deviceid;

    public Appusage() {
    }

    public Appusage(Integer usageId) {
        this.usageId = usageId;
    }

    public Date getDateUsed() {
        return dateUsed;
    }

    public void setDateUsed(Date dateUsed) {
        this.dateUsed = dateUsed;
    }

    public Integer getDuration() {
        return duration;
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    public Integer getUsageId() {
        return usageId;
    }

    public void setUsageId(Integer usageId) {
        this.usageId = usageId;
    }

    public Usertable getUserId() {
        return userId;
    }

    public void setUserId(Usertable userId) {
        this.userId = userId;
    }

    public Application getAppId() {
        return appId;
    }

    public void setAppId(Application appId) {
        this.appId = appId;
    }

    public Device getDeviceid() {
        return deviceid;
    }

    public void setDeviceid(Device deviceid) {
        this.deviceid = deviceid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usageId != null ? usageId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Appusage)) {
            return false;
        }
        Appusage other = (Appusage) object;
        if ((this.usageId == null && other.usageId != null) || (this.usageId != null && !this.usageId.equals(other.usageId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mlbs.entity.Appusage[usageId=" + usageId + "]";
    }

}
